﻿using System;
using System.Collections.Generic;
using System.Windows.Media.Media3D;
using LFSRecord2.Misc;

namespace LFSRecord2.Model
{
    public class CompLayerReplayControl : CompLayerBase
    {
        public enum PropertyTypes
        {
            ReplayName = 0,
            TimeOffset = 1,
        }

        [Flags]
        public enum PropertyTypesFlags
        {
            None = 0,
            ReplayName = 1,
            TimeOffset = 2,
        }

        public CompLayerReplayControl(short layerIndex, string layerName)
        {
            UniqueID = MathHelper.UniqueID;
            LayerIndex = layerIndex;
            LayerType = CompLayerTypes.ReplayControl;
            LayerName = layerName;
            IsActiveCamera = false;

            // Setup properties
            Properties = new List<CompLayerPropertyBase>(2);
            Properties.Add(new CompLayerPropertyString(this, 0, "Replay", "", LayerPropertyValueMeaning.Generic));
            Properties.Add(new CompLayerPropertyDouble(this, 1, "Time Offset", 0, LayerPropertyValueMeaning.Timestamp));

            ((CompLayerPropertyDouble)Properties[(int)PropertyTypes.TimeOffset]).MinValue = 0;
        }

        public bool HasReplay()
        {
            CompLayerPropertyString prop = (CompLayerPropertyString)Properties[0];
            if (prop.CurrentValue.Length > 0)
                return true;
            if (prop.KeyFrames.Count > 0)
            {
                foreach (CustomStringKeyFrame kf in prop.KeyFrames)
                {
                    if (kf.Value.Length > 0)
                        return true;
                }
            }

            return false;
        }

        public override Matrix3D GetTransformMatrixAtFrame(int frame)
        {
            return new Matrix3D();
        }

        public override void SetMeshLookAtPointAtFrame(int frame)
        {
        }

        public override void SetMeshCenterPointAtFrame(int frame)
        {
        }

        public override void RemoveParentingJump(CompLayerBase parentLayer)
        {
        }

        public override void AddParentingJump()
        {
        }
    }
}
